/**
 * @file test4.cpp
 * @author Xin Yuan
 *
 * Modified by: Alejandro Cabrera
 *  - Removed unnecessary headers
 *  - main() meets C standard
 */
#include <iostream>
#include "../include/mm.h"

using namespace std;

int main()
{
  MemoryManager m(210,200);
  char *p[10];
  int *ii;

  // step 1
  p[0] = (char *) m.mymalloc(1);
  if (p[0] != NULL) {
    *p[0] = 'a';
  }
  else {
    cout << "P[0] allocation failed.\n";
  }

  // step 2
  p[1] = (char *) m.mymalloc(2);
  if (p[1] != NULL) {
    p[1][0] = 'b';
    p[1][1] = 'b';
  }
  else {
    cout << "P[1] allocation failed.\n";
  }

  // step 3
  ii = (int *) m.mymalloc(4);
  if (ii != NULL) {
    *ii = 0xff;
  }
  else {
    cout << "ii allocation failed.\n";
  }

  // step 4
  p[3] = (char *) m.mymalloc(4);
  if (p[3] == NULL) {
    cout << "p[3] allocation failed.\n";
  }
  printf("*p[0] = %c, *p[1] = %c, *ii = %d\n", *p[0], *p[1], *ii);

  m.printUseList();
  m.printMemoryStatus(100);

  return 0;
}
